package com.kbcss.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class IeInfoInsert
 */
public class IeInfoInsert extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public IeInfoInsert() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("text/html");
		PrintWriter out=response.getWriter();
		RequestDispatcher rd;
		HttpSession ss=request.getSession();
		String uid=(String)ss.getAttribute("id");
		String org=request.getParameter("org");
		String desig=request.getParameter("desig");
		String quali=request.getParameter("quali");
		int xx=0;
		try{
		     Class.forName("com.mysql.jdbc.Driver");
		     Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/kbcssdb", "root", "mysql");
		     PreparedStatement ps=con.prepareStatement("insert into indexpdetails(userid,company,designation,qualification) values(?,?,?,?)");
		     ps.setString(1,uid);
		     ps.setString(2,org);
		     ps.setString(3,desig);
		     ps.setString(4,quali);
		     xx=ps.executeUpdate();
	}
	catch(Exception ex){
		out.println("error...."+ex.getMessage());
	}
		if(xx==1){
			rd=request.getRequestDispatcher("iprofile1.jsp");
			rd.forward(request,response);
		}
	}

}
